package mapping;

import generation.duration.CellSpeed;
import generation.duration.Duration;
import util.Utils;

public class Mapper {

	public static CellSpeed mapInputToSpeed(float input){
		int index = Math.round(Utils.map(input, 0.0f, 1.0f, 0, CellSpeed.values().length - 1));
		return CellSpeed.values()[index];
	}
	
	public static Duration mapInputToDuration(float input){
		int index = Math.round(Utils.map(input, 0.0f, 1.0f, 0, Duration.values().length - 1));
		return Duration.values()[index];
	}
	
	private static void testMapInputToSpeedMethod() {
		System.out.println(Mapper.mapInputToSpeed(0));
		System.out.println(Mapper.mapInputToSpeed(0.1f));
		System.out.println(Mapper.mapInputToSpeed(0.2f));
		System.out.println(Mapper.mapInputToSpeed(0.3f));
		System.out.println(Mapper.mapInputToSpeed(0.4f));
		System.out.println(Mapper.mapInputToSpeed(0.5f));
		System.out.println(Mapper.mapInputToSpeed(0.6f));
		System.out.println(Mapper.mapInputToSpeed(0.7f));
		System.out.println(Mapper.mapInputToSpeed(0.8f));
		System.out.println(Mapper.mapInputToSpeed(0.9f));
		System.out.println(Mapper.mapInputToSpeed(1.0f));
	}
	
	private static void testMapInputToDuration(){
		System.out.println(Mapper.mapInputToDuration(0.0f));
		System.out.println(Mapper.mapInputToDuration(0.1f));
		System.out.println(Mapper.mapInputToDuration(0.2f));
		System.out.println(Mapper.mapInputToDuration(0.3f));
		System.out.println(Mapper.mapInputToDuration(0.4f));
		System.out.println(Mapper.mapInputToDuration(0.5f));
		System.out.println(Mapper.mapInputToDuration(0.6f));
		System.out.println(Mapper.mapInputToDuration(0.7f));
		System.out.println(Mapper.mapInputToDuration(0.8f));
		System.out.println(Mapper.mapInputToDuration(0.9f));
		System.out.println(Mapper.mapInputToDuration(1.0f));
	}

	public static void main(String[] args) {
		testMapInputToSpeedMethod();
		testMapInputToDuration();
		//System.out.println(Duration.w.toString());
	}
}
